package gdut.imis.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import gdut.imis.Utils.Result;
import gdut.imis.domain.MatchesTeam;
import gdut.imis.enums.Status;
import gdut.imis.mapper.MatchesTeamMapper;
import gdut.imis.service.MatchesTeamService;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/8 18:52
 */
@Service
public class MatchesTeamServiceImpl extends ServiceImpl<MatchesTeamMapper, MatchesTeam> implements MatchesTeamService {

    /***
     * 新增队伍与比赛关联
     * @param: matchesTeam
     * @return Result
     */
    @Override
    public Result addTeams(MatchesTeam matchesTeam) {
        if (Objects.isNull(matchesTeam)) {
            return Result.errorWithArgs(Status.REQUEST_PARAMS_NOT_VALID_ERROR, "clubInstitution");
        }
        boolean flag = this.save(matchesTeam);
        if (flag) {
            return Result.success();
        }
        return Result.errorWithArgs(Status.FAILED, "新增比赛队伍失败");
    }
}
